Wiki source code of Home Assistant Tips'n'Tricks

Last modified by Normann P. Nielsen on 2023/05/16 21:15

Show last authors
1 {{success}}Most of this stuff is outdated - and I have become a somewhat wiser man (on Home Assistant). Do use [[Docke>>Main.information-technology.home-assistant.home-assistant-on-docker]]r instead of the installation process below etc.{{/success}}
2
3
4
5 {{toc/}}
6
7 = Custom Installation =
8
9 === Upgrade the Home Assistant installation ===
10 On my Ubuntu (See [[https://www.home-assistant.io/docs/installation/virtualenv/]])
11
12
13 {{code}}
14 sudo su -s /bin/bash homeassistant
15 source /srv/homeassistant/bin/activate
16 pip3 install --upgrade homeassistant
17 {{/code}}
18
19
20
21 === Update pyatv ===
22
23 {{code}}
24 sudo su -s /bin/bash homeassistant
25 source /srv/homeassistant/bin/activate
26 pip3 install --upgrade pyatv
27 {{/code}}
28
29
30
31 = Renaming Devices etc =
32
33 As stupid as it is, You cant rename via the GUI - this will give:
34
35 [[image:Screenshot 2018-12-15 at 16.57.05.png||alt="Screenshot 2018-12-15 at 16.57.05.png"]]
36
37 The trick is to edit the file core.entity_registry
38
39
40 {{code}}
41 cd .storage
42 vi core.entity_registry
43 {{/code}}
44
45 Change:
46
47
48 {{code}}
49 {
50 "config_entry_id": null,
51 "device_id": null,
52 "disabled_by": null,
53 "entity_id": "remote.sovevrelse",
54 "name": "null,
55 "platform": "apple_tv",
56 "unique_id": "9465bb10bf1214d769bd2aca8377aaa5203e09ae3ea4a353a02d80e3e71e149c"
57 }
58 {{/code}}
59
60 to
61
62
63 {{code}}
64 {
65 "config_entry_id": null,
66 "device_id": null,
67 "disabled_by": null,
68 "entity_id": "remote.sovevrelse",
69 "name": "Apple TV Soveværelse Remote",
70 "platform": "apple_tv",
71 "unique_id": "9465bb10bf1214d769bd2aca8377aaa5203e09ae3ea4a353a02d80e3e71e149c"
72 }
73 {{/code}}
74
75 And restart Home Assistant
76
77 = ZenseHome Office Light =
78
79 See more at [[ZenseHome API interfacing>>Main.information-technology.zensehome-api-interfacing]]
80
81
82 {{code}}
83 switch:
84 platform: command_line
85 switches:
86 office_light:
87 command_on: /var/turnon-office.exp
88 command_off: /var/turnoff-office.exp
89 friendly_name: Office Lights
90 kitchen_light:
91 command_on: /var/turnon-kitchen.exp
92 command_off: /var/turnoff-kitchen.exp
93 friendly_name: Kitchen Lights
94 {{/code}}
95
96
97
98 = Adding HIK/Trendnet Cams =
99
100 {{success}}Some discussion on Reddit [[here>>https://www.reddit.com/r/homeassistant/comments/8nv8x0/ffmpeg_camera_stream_issues_playing_at_2x_or/]]{{/success}}
101
102
103
104 Install ffmpeg on Linux
105
106
107 {{code}}
108 apt-get install ffmpeg
109 {{/code}}
110
111
112
113 Add som config (see [[https://www.home-assistant.io/components/ffmpeg/]]):
114
115
116 {{code language="Still"}}
117 ffmpeg:
118 ffmpeg_bin: /usr/bin/ffmpeg
119
120
121 camera 41:
122 - platform: generic
123 still_image_url: http://admin:******@10.0.0.140:80/PSIA/Streaming/channels/1/picture
124 name: Bag hus
125
126 - platform: generic
127 still_image_url: http://admin:******@10.0.0.130:80/PSIA/Streaming/channels/1/picture
128 name: Fordør
129
130 {{/code}}
131
132
133 {{code language="Stream"}}
134 ffmpeg:
135 ffmpeg_bin: /usr/bin/ffmpeg
136
137 camera:
138 - platform: ffmpeg
139 input: rtsp://admin:******@10.0.0.140:554/Streaming/Channels/1
140 name: Bag hus (stream)
141
142 - platform: ffmpeg
143 input: rtsp://admin:******@10.0.0.130:554/Streaming/Channels/1
144 name: Fordør (stream)
145 {{/code}}
146
147
148
149 = NMap =
150
151
152 {{code}}
153 apt-get install nmap
154 sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip
155 sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip /usr/bin/nmap
156 {{/code}}
157
158
159 {{code}}
160 device_tracker:
161 - platform: nmap_tracker
162 hosts: 10.0.0.0/24
163
164 {{/code}}
165
166
167
168 = Sony Songpal discover =
169
170
171 {{code}}
172 songpal discover
173
174
175 Found SRS-X77 - MINT1.9.1
176 * API version: 1.0
177 * Endpoint: http://10.0.0.114:54480/sony
178 * Services:
179 - Service: guide
180 - Service: audio
181 - Service: avContent
182 - Service: system
183 Found STR-DN1060 - STR-2015
184 * API version: 1.0
185 * Endpoint: http://10.0.0.120:10000/sony
186 * Services:
187 - Service: guide
188 - Service: system
189 - Service: audio
190 - Service: avContent
191 {{/code}}
192
193 = Plex =
194
195 Getting the TOKEN:
196
197
198 {{code}}
199 root@robin:~/homeassistant# curl -X "POST" "https://plex.tv/users/sign_in.json" \
200 > -H "X-Plex-Version: 1.0.0" \
201 > -H "X-Plex-Product: Home Automation" \
202 > -H "X-Plex-Client-Identifier: NPN" \
203 > -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
204 > --data-urlencode "user[password]=******" \
205 > --data-urlencode "user[login]=bnp@mos-eisley.dk"
206 {"user":{"id":********,"uuid":"**********","email":"bnp@mos-eisley.dk","joined_at":"2015-10-16T13:37:33Z","username":"bnp@mos-eisley.dk","title":"bnp@mos-eisley.dk","thumb":"https://plex.tv/users/**************/avatar?c=*********","hasPassword":true,"authToken":"**************","authentication_token":"*********","subscription":{"active":false,"status":"Inactive","plan":null,"features":["adaptive_bitrate","collections","photos-metadata-edition","radio","photos-favorites","federated-auth","Android - PiP","publishing_platform","news","kevin-bacon","client-radio-stations","TREBLE-show-features","web_server_dashboard","conan_redirect_qa","conan_redirect_alpha","conan_redirect_beta","conan_redirect_public","news_local_now","transcoder_cache","artist-tv"]},"roles":{"roles":[]},"entitlements":[],"confirmedAt":"2015-10-16T13:40:18Z","forumId":null,"rememberMe":false}}
207 {{/code}}
208
209 Add it to
210
211
212 {{code language="plex.conf"}}
213 {
214 "10.0.0.150:32400": {
215 "ssl": false,
216 "token": "*********",
217 "verify": true
218 }
219 }
220 {{/code}}
221
222
223
224 = BitBucket =
225
226 For Backup and change tracking, I use BitBucket.
227
228 [[https://bitbucket.org/moseiseydk/home-assistant/src/master/]]
229
230 = Links =
231
232 [[https://diyfuturism.com/index.php/2017/11/26/presence-detection-with-home-assistant-bayesian-probability/]]
233
234 [[https://www.reddit.com/r/homeassistant/comments/57arhl/multiple_device_trackers_aggregation/]]
235
236
237
238 = MQTT =
239
240 Start a MQTT Docker instance
241
242
243 {{code}}
244 docker run --init --restart on-failure --name mqtt --restart=always --net=host -p 1883:1883 -d ansi/mosquitto
245 {{/code}}