hi, thank you for your work!
how do you think to update the states of the sensor? like if i activate a scenario on my phone how can we know it changed ? we have to call the update request every 5 10 seconds?
Hi everyone, to complete the explanation of @pla10 iâll paste here the steps i used to get the clientid and token + all the get requests.
- Download mitmproxy
- Download PCAPdroid on your phone
- Download AlienMobile on your phone(inim home will work too), modify the apk to remove certificate pinning with this tool
- On windows open cmd and type mitmproxy, then go to C:\Users<User>\.mitmproxy, copy mitmproxy-ca-cert.pem certificate to your phone and install it! (On newest android phone you canât install it by clicking on it but you have to search the menu in your phone settings)
- Go back to cmd and this time type:
mitmweb --mode socks5 --listen-port 8080
- On your phone open PCAPdroid, click the gear icon on the right and turn on SOCKS5 Proxy, then fill your windows pc ip and 8080 for the port
- Before starting the application, make sure to activate the app filter and choose the AlienMobile app.
Once youâve done that you can press the start button(it will ask you if you want to save the pcap file, it is indifferent do what you want).
When youâll open the AlienMobile app and after configuring your inim central youâll start seeing all the get requests on the web interfaces with request parameters and responses, including token and clientId
Now we need to figure out how and when to poll data from get requests to update sensors in home assistant.
I was wandering too if calling the authenticate request will add lifetime to the token, reply to me if you need help
Thank you @Nikitarex for the in-depth explanation on how to sniff the data from the app (I used Burp Suite, but any network analysis tool with an integrated proxy can do the job).
Right now Iâm requesting the updates every 10 seconds.
This is my current flow in NodeRED:
If anyone has any idea on how to automate the login and retrieve an updated token it would be perfect!
have you tried calling the authenticate request before the other 2?
Yes, actually i have 2 of them iâll list every command i found in case someone needs it:
-
Authenticate
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"Authenticate","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{}}
-
Authenticate code
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"AuthenticateCode","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>,"Code":<USER PIN CODE>,"Role":"1"}}
-
Get active scenario + other info
https://api.inimcloud.com/?req={"Params":{"Info":4223},"Node":"","Name":"Inim Home","ClientIP":"","Method":"GetDevicesExtended","Token":<token>,"ClientId":<clientID>,"Context":"intrusion"}
-
Get scenarios
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"GetDeviceScenarios","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Activate scenario
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"ActivateScenario","ClientId":<CLIIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>,"ScenarioId":<ID_SCENARIO>}}
-
Update sensors
https://api.inimcloud.com/?req={"Params":{"DeviceId":<DEVICEID>,"Type":5},"Node":"","Name":"Inim Home","ClientIP":"","Method":"RequestPoll","Token":<TOKEN>,"ClientId":<CLIENTID>,"Context":"intrusion"}
-
Get areas
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"GetDeviceAreas","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Get zones
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"GetDeviceZones","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Get status(voltage faults)
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"ReadStatus","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Get items
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"GetDeviceItems","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Read item
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"ReadItem","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>,"ItemId":<ITEMID>,"Type":<TYPE>}}
-
Read log
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"ReadLogEntries","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>}}
-
Read unready zones
https://api.inimcloud.com/?req={"Node":"","Name":"AlienMobilePro","ClientIP":"","Method":"ReadUnreadyZones","ClientId":<CLIENTID>,"Token":<TOKEN>,"Params":{"DeviceId":<DEVICEID>,"Element":<ID SCENARIO?>,"Type":1,"Mode":0}}
If you could explain better the integration in home assistant, it helps, because i tried REST integration but something isnât working wile reading the json response.
I get:
Template variable error: dict object has no element 12345 when rendering '{{ value_json.Data.12345.ActiveScenario }}'
(i donât use node red so if you could explain youâre doing me a favour)
I manged to integrate a sensor with REST that display the active scenario, here is the config:
- platform: rest
name: poll request
scan_interval: 10
resource: 'https://api.inimcloud.com/?req={"Params":{"DeviceId":"DEVICEID","Type":5},"Node":"","Name":"Inim Home","ClientIP":"","Method":"RequestPoll","Token":"TOKEN","ClientId":"CLIENTID","Context":"intrusion"}'
- platform: rest
name: inimrest
scan_interval: 10
resource: 'https://api.inimcloud.com/?req={"Params":{"Info":4223},"Node":"","Name":"Inim Home","ClientIP":"","Method":"GetDevicesExtended","Token":"TOKEN","ClientId":"CLIENTID","Context":"intrusion"}'
value_template: >-
{% if value_json.Data['DEVICEID'].ActiveScenario == 1 %}
DIS.TOTALE
{% elif value_json.Data['DEVICEID'].ActiveScenario == 2 %}
INS.CONT.FINESTRE
{% elif value_json.Data['DEVICEID'].ActiveScenario == 3 %}
INS.RAD.ESTERNI
{% elif value_json.Data['DEVICEID'].ActiveScenario == 4 %}
DIS.RAD.ESTERNI
{% elif value_json.Data['DEVICEID'].ActiveScenario == 5 %}
INS.RAD.TAVERNA
{% else %}
IMP.DETERMINARE
{% endif %}
Good morning
- Download mitmproxy
- Download PCAPdroid on your phone
- Download AlienMobile on your phone(inim home and inim home p2p wonât work)
Are these operations to be carried out using a local ip or can they also be performed on inim cloud?
Thank you
Hi, you have to be on the same network as the alarm, yes login in the alienmobile with local ip,
Last time i tried adding the alarm via inimcloud to the alienmobile app it didnât work.
Thank youâŚ
I will try as you suggested, I managed to configure alienmobile with cloud and it works.
Hello
Hi @pla10,
Did you manage to get everything working with the card SmartLan SI?
I will buy one, and wondering whether I should go for a G, or the SI will be enough?
My goal is to integrate everything on the Home Assistant (and be able to control the alarm remotely, also get notifications when it is triggered, etc), and also make use of the PIR sensors for another automations.
Thanks!
Hi, sorry for the late reply. My setup is working, but it has only one flaw. I need to manually change the token once in a while so it will keep working. I didnât manage yet to fix this automatically.
You need to go with a G card.
For people who have an older INIM setup and who do calls to their local device, not to the cloud, the newest NodeRed update creates an error when using the Http Request Node. The error is: âHPE invalid header tokenâ. Apparently the latest NodeRed version has become more strict in evaluating the response from the server. After some digging my conclusion is that my version of the firmware responds with the âContent-Typeâ header in the wrong order which I cannot fix. When executing from Postman there are no errors. I cannot update the firmware, so I had to find a workaround.
The type of workaround depends on the length of INIM systemâs reply. Responses with a length over 255 need special treatment. So here is how I solved it:
# Short reply: Test for alarm scenario state, since http request node in nodered not working anymore
- platform: command_line
name: alarm_scenario_state
command: 'curl -k "http://192.168.1.92:5050/cgi-bin/web.cgi?mod=sce&user=myusername&pass=mypassword&code=mycode&par=now"'
value_template: '{{ value_json.lb }}'
# Response can be used in NodeRed and HA by using 'sensor.alarm_scenario_state'
#Another short reply
- platform: command_line
name: alarm_states
command: 'curl -k "http://192.168.1.92:5050/cgi-bin/web.cgi?mod=cmd&user=myusername&pass=mypassword&code=mycode"'
# Creates a 'sensor.alarm_states' with json data that can be used in NodeRed and HA
# If the response is more than 255 characters, we need a different solution
# We cannot use the response in its entirety, we need to break it up in parts by using "attributes"
- platform: rest
name: alarm_partition_states
resource: http://192.168.1.92:5050/cgi-bin/web.cgi?mod=part&user=myusername&pass=mypassword&code=mycode
scan_interval: 60
json_attributes:
- part
value_template: "OK"
- platform: template
sensors:
alarm_partition_keuken:
value_template: '{{ state_attr("sensor.alarm_partition_states", "part") [0] }}'
alarm_partition_bggkelder:
value_template: '{{ state_attr("sensor.alarm_partition_states", "part") [1] }}'
alarm_partition_studeerkamers:
value_template: '{{ state_attr("sensor.alarm_partition_states", "part") [2] }}'
# creates json data in sensor that can be processed in NodeRed, but need convert the single quotes in the response to double quotes in a function node
It is also impossible to download the alarm report using the http request node. The work around for this one is to create a shell_command. This commands downloads the report (in json) and saves it as a textfile in the â/share/âŚ/â directory:
shell_command:
save_inim_alarm_report_to_disk_as_json: 'curl -k "http://192.168.1.92:5050/cgi-bin/web.cgi?mod=log&par={{states("input_number.inim_report_lines")}}&user=myusername&pass=mypasscode&code=mycode" -o "/share/inim/output_from_inim_as_json.txt" '
In NodeRed I read the file from disk, create a json object, reverse the order of the report lines, put the resulting data in a html template, then save this html file to disk adding a random number 0000-9999 to the filename. Just before this last step I deleted the old html file, to ensure we do not keep any data we do not need. The filename and random number gets saved in a Home Assistant sensor.
We need to take the random number step, because a fixed filename gets stuck in the browser cache and I have not found an easy way to flush it. Because the filename changes all the time, the cache is not an issue.
To present this alarm report in the front end, I use a browser_mod 2.0 popup card that calls up the html file in an âiframeâ card. The number of lines in the report is set with a slider. A new report gets generated every 10 minutes or when an alarm goes off or when the number of report lines is changed.
NodeRed code available on request.
Hi @pla10, @Jan_Willem_Maas, Thanks a lot for the reply, very much appreciated. I was still having doubts on which version to go, seems that I must go the G. Cheers
Hi all.
I have a Inim SmartLiving 515, but we barely use it, like almost never actually.
So Iâm not that much interested into this right now, I mean the security/alarms it provided.
However almost every room in my house has those motion sensors connected to the Inim SmartLiving box, and I would like to create some automations in my house based on those motion sensors status.
Any idea if is possible to get those sensors in a ESPHome or access them somehow useful in Home Assistant?
I donât have the SmartLan accessory card, I could buy it eventually, but I donât know if querying the local api every 1 second to get the status of those motion sensors is a good idea (is this actually possible to get the status of a motion sensor?), could that be overkill?
I got rid of the inim alarm box and replaced it with Konnected panels using the original inim sensors. Perfectly integrated into home assistant. Sold the inim box for a higher price than the konnected panels
What do you mean by inim alarm box and original sensors? With which part of Konnected panels you made the swap?
What info is exposed in HA? Can you post a screenshot?
Iâm not that reluctant to change the Inim as I donât use it much anyway, so I doubt I would use the alarm feature of the Konnected or any other alarm system whatever what it might be.
For now I only want to tap into the existing sensors (motion sensors) and see if I could use those for other projects as well.
All sensors in the INIM alarm are connected with 2 simple wires from the sensor to the âboxâ (INIM SmartLiving 1050 in my case).
If the wires are continuous, the sensor is âsafeâ (no motion, door closed, window closed).
If the wires are interrupted, the sensor is detecting motion, door/window open, âŚ
I got rid of the INIM SmartLiving and replaced it with Konnected panels (Konnected Alarm Panel Wired Alarm System Conversion/Interface Kits â Konnected Inc.)
The Konnected panels are infinitely customizable in Home Assistant but they will just expose the individual sensors. You will have to make your own alarm logic, which is super easy with the Alarmo integration (GitHub - nielsfaber/alarmo: Easy to use alarm system integration for Home Assistant)
Finally, a screenshot of one of my Konnected panels (I installed 1 on each floor, because that was easiest in my case)
Hi I have a Smartliving with Smartlan/SI. My alarm is connected to inimcloud, someone has figured out how to let talk HA with inim cloud in order to activate or deactivate scenarios?
Thanks