refactored code for rendering sensor with template
refactored code fore rendering sensor with template2