Wiki source code of Home Assistant Tips'n'Tricks

Last modified by Normann P. Nielsen on 2025/12/12 15:13

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